/*
 * comm_wifi.h
 *
 *  Created on: Oct 15, 2021
 *      Author: Administrator
 */
#ifndef _WIFI_COMM_H
#define _WIFI_COMM_H

#include "machine_stat.h"
#include "string.h"
#include "comm.h"

#define WIFI_INTI         0
#define WIFI_START        1
#define WIFI_START_ACK    2
#define SIGNAL_LIMIT      3
#define WIFI_ACK_1        4
#define NET_STAT          5
#define WIFI_ACK_2        6
#define LINK_STAT         7
#define WIFI_ACK_3        8
#define WIFI_INFOR        9
#define WIFI_RES_1        10
#define WIFI_RUN          11
#define WIFI_ACK          12
#define WIFI_REset        13
#define WIFI_ACK_5        14
#define WIFI_Information  15
#define WIFI_RES_2        16
#define WIFI_RESET_1        17
#define WIFI_RESET_ACK    18
#define WIFI_F0_RES       19
#define WIFI_F1_RES       20
#define WIFI_F2_RES       21
#define WIFI_F0_F1_F2_GET           22
#define WIFI_SEND_ACK_RES_IS_OK     99
#define WIFI_UNLINK          100


#define WIFI_STXdata 0
#define WIFI_SORTdata 1
#define WIFI_LENGTHdata 2
#define WIFI_COMMANDdata 3
#define WIFI_TEXTdata 4
#define WIFI_ETXdata 5
#define WIFI_BCCdata 6



#define stx_date 0x02
#define sort_date 0x09
#define etx_date 0x03

#define WIFI_TEXT_SET        0x53
#define WIFI_TEXT_GET        0x47
#define WIFI_TEXT_RES        0x52
#define WIFI_TEXT_INF        0x49
#define WIFI_TEXT_ACK        0x41
#define WIFI_TEXT_NAK        0x4E

typedef enum{
	OFFLINE,
	ONLINE,//1
}NET_Stat ;

typedef enum{
    SMARTLINK_FAILED ,
    SMARTLINK_SUCCESS,//1
}SMARTLINK_Stat;

typedef enum{
    NO_SIGNAL,
    LOW,
    MID,
    HIGH,
}SIGNAL_Stat;

typedef enum{
	NO_connect,
	connect,
}WIFI_CONNECT_STAT;

typedef struct{
	NET_Stat       net_stat; //aaron,
	SMARTLINK_Stat smart_link_stat;//
	SIGNAL_Stat    signal;
}WIFI_Stat;

typedef struct{
    uint8_t  wifi_power;
    uint8_t  wifi_eco;
    uint8_t  wifi_eco_temp;
    uint8_t  wifi_akey_cycle;
	uint8_t  wifi_cycle_mode;
	uint8_t  wifi_cycle_book;
    uint8_t  wifi_super_mode;
	uint8_t  wifi_running_mode;
}WIFI_send;

typedef struct{
	//uint8_t run_modes;
	uint8_t init_temp;
	uint8_t min_temp;
	uint8_t max_temp;
}RUN_mode;

typedef struct 
{
		WIFI_CONNECT_STAT  wifi_smartlink_stat;
		WIFI_CONNECT_STAT  wifi_server_stat;
		WIFI_CONNECT_STAT  wifi_net_stat;
}CONNECT_WIFI;

extern CONNECT_WIFI wifi_connect;
//extern uint8_t dis_signal;
extern uint8_t dis_runmode;

extern RUN_mode runing_mode[3];

extern WIFI_Stat wifi_stat;
extern WIFI_send wifi_heater_info;

void wifi_start_massage(void);
void wifi_infor_massage(void);
void wifi_chack_massage(void);
void wifi_ack_massage(void);
void wifi_reset_data(void);
uint8_t wifi_comm_process(uint8_t cmd);
void wifi_get_data(void);
void wifi_get_process(uint8_t wifi_data);


#endif